<?php $this->load->view('header_solicitud'); ?>
<?php $this->load->view('cuerpo'); ?>
<style type="text/css">
    th, td {
        white-space: nowrap;
    }
    div.dataTables_wrapper {
        width: 100%;
    }
    td.details-control {
        background: url('../images/details_open.png') no-repeat center center;
        cursor: pointer;
    }
    tr.shown td.details-control {
        background: url('../images/details_close.png') no-repeat center center;
    }
</style>
<script type="text/javascript" charset="utf-8">    
    $(document).ready(function() {
        $.datepicker.regional[""].dateFormat = 'dd/mm/yy';
        $.datepicker.setDefaults($.datepicker.regional['']);
        $('#solicitud').DataTable({
            "bJQueryUI": true,
            "scrollX": true,
            "sPaginationType": "full_numbers",
            "lengthMenu": [[5, 10, 25, 50, -1], ["05", "10", "25", "50", "Todo"]],
            "columns": [
                { "orderable":      true },
                { "orderable":      true },
                { "orderable":      true },
                { "orderable":      true },
                { "orderable":      true },
                { "orderable":      true },
                { "orderable":      true },
                { "orderable":      true },
                { "orderable":      true },
                { "orderable":      false },
                { "orderable":      false },
                { "orderable":      false }
            ],
            "order": [[0, 'desc']]
        });  
        $('#solicitud').dataTable()
        	.columnFilter({
					sPlaceHolder: "head:before",
					aoColumns: [ {type: "date-range"},
					             {type: "date-range"}
								
								]
            	});      
    });
</script>
<section id="dt_solicitud">
    <div id="container" style="width: 100%;">
        <table border="1" class="display" id="solicitud" width="100%">
            <thead>
            	<tr>
            		<th colspan="12" style="text-align: justify;">
            		</th>
            	</tr>
                <tr>
                	<th>VER</th>
                    <th>COTIZAR</th>
                    <th>ANULAR</th>
                    <th>N° SOLICITUD</th>
                    <th>FEC. REGISTRO</th>
                    <th>MONEDA</th>
                    <th>PLACA</th>
                    <th>TALLER</th>
                    <th>MARCA</th>
                    <th>MODELO</th>
                    <th>AÑO</th>
                    <th>ESTADO</th>                    
                </tr>
            </thead>
            <tbody>
            <?php
                $item = 1;
                foreach($lstSolicitud as $data) {
                    $codigo = '';
                    $numCaracteres = strlen($data->id_solicitud);
                    for($iPos=0;$iPos<$tamCodigo-$numCaracteres;$iPos++) {
                        $codigo .= '0';
                    }
                    $codigo .= $data->id_solicitud;
                    
                    $nomTaller = '';
                    if ($data->nomTaller != '') {
                        $nomTaller = $data->nomTaller;
                    } else {
                        $nomTaller = $data->otroTaller;
                    }
            ?>
            <tr>
            	<td class="center">
                    <a href="<? echo base_url();?>index.php/solicitud/nuevo?id=<?=$data->id_solicitud?>&lectura=1" title="Ver">
                        <img src="<? echo base_url();?>images/ver.png" width="20" height="20" title="Ver"/>
                    </a>
                </td>
                <td class="center">
                    <?php
                            if ($data->idEstado == $estadoSuspendida) {
                    ?>
                    <a href="<? echo base_url();?>index.php/solicitud/nuevo?id=<?=$data->id_solicitud?>" title="Cotizar">
                        <img src="<? echo base_url();?>images/cotizar.png" width="20" height="20" title="Cotizar"/>
                    </a>
                    <?php
                            } else {
                                if ($data->idEstado == $estadoConRespuesta) {
                    ?>
                    <a href="<? echo base_url();?>index.php/cotizacion/ver?id=<?=$data->id_solicitud?>" title="Cotizar">
                        <img src="<? echo base_url();?>images/cotizar.png" width="20" height="20" title="Cotizar"/>
                    </a>
                    <?php
                                } else {
                    ?>
                    <span>-</span>
                    <?php
                                }
                            }
                    ?>
                </td>
                <td class="center">
                    <?php if ($data->idEstado == $estadoSuspendida || $data->idEstado == $estadoEnviada || $data->idEstado == $estadoConRespuesta) { ?>
                    <a onclick="return confirm('¿Está seguro de anular la Solicitud?')"
                        href="<? echo base_url();?>index.php/solicitud/anular?id=<?=$data->id_solicitud?>" title="Anular">
                        <img src="<? echo base_url();?>images/eliminar.png" width="20" height="20" title="Anular"/>
                    </a>
                    <?php } else { ?>
                    <span>-</span>
                    <?php } ?>
                </td>
                <td class="center"><?= $codigo; ?></td>
                <td class="center"><?php echo date("d/m/Y", strtotime($data->fecha_registro)) ?></td>
		<td class="left"><?= $data->nomMoneda ?></td>
                <td class="left"><?= $data->placa ?></td>
                <td class="left"><?= $nomTaller ?></td>
                <td class="left"><?= $data->nomMarca ?></td>
                <td class="left"><?= $data->nomModelo ?></td>
                <td class="center"><?= $data->anho ?></td>
                <?php if ($data->idEstado == $estadoOGenerada) { ?>
                <td class="left">
                    <a href="<? echo base_url();?>index.php/cotizacion/seguir?id=<?=$data->id_solicitud?>"><?php echo $data->nomEstado ?></a>
                </td>
                <?php } else { ?>
                <td class="left"><?= $data->nomEstado ?></td>
                <?php } ?>
            </tr>
            <?php } ?>
            </tbody>
	</table>
    </div>
    <div style="padding-top: 10px;">
        <table style="width: 100%; text-align: center;">
            <tr>
                <td>
                    <input type="button" value="Nuevo" onclick="nuevo()" style="font-size: 11px;"/>
                    <script>
                        function nuevo() {
                            window.location="<? echo base_url();?>index.php/solicitud/nuevo";
                        }
                    </script>
                </td>
            </tr>
        </table>
    </div>
</section>
<?php $this->load->view('footer'); ?>